﻿using System;
using System.Collections.Generic;
using System.Text;

namespace NFinal
{
    /// <summary>
    /// URL生成帮助类
    /// </summary>
    public class UrlHelper
    {
        /// <summary>
        /// 获取Url
        /// </summary>
        /// <typeparam name="TController">控制器类型</typeparam>
        /// <param name="methodName">Action函数名</param>
        /// <param name="parameters">Url所需的参数</param>
        /// <returns>返回调用该Action的Url</returns>
        public string GetUrl<TController>(string methodName, params StringContainer[] parameters)
        {
            return NFinal.Config.Configration.globalConfig.server.url + NFinal.Url.ActionUrlHelper.Format(NFinal.Url.ActionUrlHelper.formatControllerDictionary[typeof(TController).TypeHandle][methodName].formatUrl, parameters);
        }
        /// <summary>
        /// 获取Content路径
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public string Content(string path)
        {
            return NFinal.Config.Configration.globalConfig.server.url + NFinal.IO.Path.MapPath(NFinal.Config.Configration.globalConfig.projectType, path);
        }
    }
}
